package com.atguigu.springcloud.consumer;

import com.atguigu.springcloud.bind.MyBind;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

/**
 * @author timiv
 */
@EnableBinding(MyBind.class)
@Component
@Slf4j
public class MqConsumer {

    @Value("${server.port}")
    private String serverPort;

    @StreamListener(MyBind.INPUT_1)
    public void input(Message<String> message){
        log.info("消费者1-1号,----->接受到的消息: {} \t port: {}",message.getPayload(),serverPort);
    }

    @StreamListener(MyBind.INPUT_2)
    public void input2(Message<String> message){
        log.info("消费者1-2号,----->接受到的消息: {} \t port: {}",message.getPayload(),serverPort);
    }
}
